package com.sun.entity.users;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.sun.entity.BaseEntity;
import com.sun.enums.UserType;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;


import java.util.List;

/**
 * MP自动填充Handler
 *
 * @Author sun
 * @CreateTime 2025/9/2 01:53
 */

@Data
@Table(name = "users")
@Entity

@SQLDelete(sql = "update users set deleted = 1 where id = ?")

public class User extends BaseEntity {
    @Id
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    private String username;
    private String password;
    private String email;
    private String phone;
    private String avatar;
    private String nickname;
    private String openid;
    @Enumerated(EnumType.STRING)
    private UserType userType;

    @ManyToMany
    //@JsonIgnore
    @JoinTable(name = "user_roles",  joinColumns = @JoinColumn(name = "userId" ), inverseJoinColumns = @JoinColumn(name = "roleId"))
    private List<Role> roles;

}
